const Router = require('koa-router')
const { register, login, getTest, currentUser, updateAvatar, updateUserDetail, jobSubject,userCount } = require('../controller/user.controller')
const { userValidator, verifyUser, cryptPassword, verifyLogin } = require('../middleware/user.middleware')
const router = new Router({ prefix: '/user' })

// 注册接口 先交给userValidator去验证，验证通过再交由register
router.post('/register', userValidator, verifyUser, cryptPassword, register)

// 登录接口
router.post('/login', userValidator, verifyLogin, login)
router.get('/currentUser', currentUser)
// 更改头像
router.post('/updateAvatar', updateAvatar)
// 完善用户信息
router.post('/updateUserDetail', updateUserDetail)
router.get('/jobSubject', jobSubject)
router.get('/userCont',userCount)
router.get('/test', getTest),

    // 导出
    module.exports = router